//门牌号问题
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n2 = 0;
	int count = 0;
	for(int i = 1;i <= 2020;i++)
	{
		/*
		string s = to_string(i);
		for(int j = 0;j < s.size();j++)
		{
			if(s[j] == '2')
				count++;
		}
		*/
		int tmp = i;
		while(tmp > 0)
		{
			if(tmp%10 == 2)
			{
				count++;
			}
			tmp /= 10;
		}
	}
	cout << count;
	return 0;
}
